import { dicAllAccountTypeApi, dicAllChannelTypeApi } from '@/apis/payment'

export default function useDicts() {
  /** 获取渠道类型字典 */
  async function getChannelDicts() {
    const { success, data } = await dicAllChannelTypeApi()
    if (success) {
      return data.map((item: Record<string, any>) => {
        return {
          label: item.value,
          value: item.key
        }
      })
    }

    return []
  }

  /** 获取账户类型数据字典 */
  async function getAccountTypeDicts() {
    const { success, data } = await dicAllAccountTypeApi()
    if (success) {
      return data.map((item: Record<string, any>) => {
        return {
          label: item.value,
          value: item.key
        }
      })
    }

    return []
  }

  return {
    getChannelDicts,
    getAccountTypeDicts
  }
}
